package com.qh.book.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.qh.book.dataobj.OrderDetail;
import com.qh.book.enums.ResultEnum;
import com.qh.book.service.OrderDetailService;

/**
 * 
 * @author qihong
 * @date 2017年10月7日 下午6:48:40 
 * @Description: 
 */
@Controller
@RequestMapping("/backstage/orderdetail")
public class OrderDetailController {

	
	@Autowired
	private OrderDetailService orderDetailService;
	
	
	@GetMapping("/listoforder")
	public ModelAndView getOrderDetailById(@RequestParam(value="orderid") String orderId,
										Map<String,Object> map) {
		
		List<OrderDetail> orderDetailList = orderDetailService.findByOrderId(orderId);
		if(orderDetailList.isEmpty()) {
			map.put("error", ResultEnum.ORDERDETAIL_ISEMPTY.getMsg());
		}else {
			map.put("orderDetailList", orderDetailList);
		}
		
		
		return new ModelAndView("/orderdetail/list",map);
	}
	
	
}
